{extend name="base" /} {block name="body"}
<div class="layui-tab layui-tab-brief">
    <ul class="layui-tab-title">
        <li class="layui-this">新增友链</li>
    </ul>
</div>
<!--tab标签-->
<div class="layui-tab-brief">
    <div class="layui-tab-content">
        <div class="layui-tab-item layui-show">
            <form class="layui-form form-container" action="{:url('admin/friendLink/save')}" data-url="{:url('admin/friendLink/save')}" method="post" localtion-url="{:url('admin/friendLink/index')}">
                <div class="layui-form-item">
                    <div>
                        <label class="layui-form-label">站点名称</label>
                        <div class="layui-input-inline">
                            <input type="text" name="title" placeholder="请输入友情连接站点名称" required lay-verify="required" autocomplete="off" class="layui-input" value="">
                        </div>
                    </div>
                    <div class="label-tint">请输入友情连接站点名称</div>
                </div>

                <div class="layui-form-item">
                    <div>
                        <label class="layui-form-label">链接地址</label>
                        <div class="layui-input-block">
                            <input type="text" name="link" placeholder="请填写带http://的全路径" required lay-verify="required" autocomplete="off" class="layui-input" value="">
                        </div>
                    </div>
                    <div class="label-tint">请填写带http://的全路径</div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">nofollow</label>
                    <div class="layui-input-block">
                        <input type="radio" name="nofollow" value="0" title="默认" checked="checked">
                        <input type="radio" name="nofollow" value="1" title="nofollow">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">排序</label>
                    <div class="layui-input-inline">
                        <input type="text" name="sort"  autocomplete="off" class="layui-input"  value="0">
                    </div>
                    <div class="label-tint">数值越大越靠前</div>
                </div>
                <div class="layui-form-item">

                    <label class="layui-form-label">QQ</label>
                    <div class="layui-input-inline">
                        <input type="text" name="poster_qq" placeholder="QQ" autocomplete="off" class="layui-input">
                    </div>


                </div>


                <div class="btable-paged">
                        <div class="formbtngroup">
                            <button class="layui-btn layui-btn-sm" lay-submit="" type="submit" lay-filter="formadd">添加</button>
                            <button onclick="history.go(-1);return false;" class="layui-btn layui-btn-primary layui-btn-sm">返回</button>
                        </div>
                </div>
            </form>
        </div>
    </div>
</div>

{/block} {block name="script"}
<script type="text/javascript" src="__ADMIN__/js/formadd.js"></script>
<script>
    layui.use(['form', 'upload'], function() {
        var form = layui.form,
            jq = layui.jquery;
        var upload = layui.upload;
        var $radio = jq('input[name="type"]');

        form.on('radio(linktype)', function(data) {

            if (data.value == 1) {
                jq("#img_area").show();
            } else {
                jq("#img_area").hide();
            } //被点击的radio的value值





        });

       var uploadInst = upload.render({
            elem: '#image2' //绑定元素
                ,
            url: '{:url("upload/upimage")}' //上传接口
                ,
            done: function(res) {
                layer.msg(res.msg, {
                    icon: 1,
                    time: 1000
                });
                jq("#cover_id").val(res.data.id);
                jq('#upload-img-box').html(
                    '<div class="upload-pre-item"><img src="' + res.data.headpath + '" width="120" height="90" /></div>'
                );
            },
            error: function() {
                layer.msg(res.msg, {
                    icon: 2,
                    time: 1000
                });
            }
        });
    })
</script>
{/block}